//author:kakake
/**
 * 医生排班
 */
class tsschedualController {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    public service: tsschedualService;
    public dao: tsschedualDao;

    constructor() {
        this.data.WorkId = TSLobsterAPI.Program.GetWorkId();

        this.service = new tsschedualService(this.data.WorkId);
        this.dao = new tsschedualDao(this.data.WorkId);

    }

    /**
     * 获取下拉框科室列表
     */
    getselectdept() {
        var data = this.dao.getselectdept();
        return { selectdata: data };
    }

    /**
     * 获取医生列表
     */
    gettabledoctor() {
        var pageInfo = {
            key: "Id",
            page: TSLobsterAPI.Program.RequestQuery("page", "1"),
            perPage: TSLobsterAPI.Program.RequestQuery("limit", "10"),
            totalRecord: 100
        };
        let deptId = TSLobsterAPI.Program.RequestQuery('deptId');
        let status = TSLobsterAPI.Program.RequestQuery('status');
        let keyword = TSLobsterAPI.Program.RequestQuery('keyword') || '';
        var data = this.dao.gettabledoctor(deptId, status, keyword, pageInfo);
        return { data: data, count: pageInfo.totalRecord };
    }

    /**
     * 生成排班
     */
    generateschedual() {
        var model = JSON.parse(TSLobsterAPI.Program.RequestBody());
        return this.service.generateschedual(model);
    }

    gettableschedual() {
        var pageInfo = {
            key: "SchedualID",
            page: TSLobsterAPI.Program.RequestQuery("page", "1"),
            perPage: TSLobsterAPI.Program.RequestQuery("limit", "10"),
            totalRecord: 100
        };

        let SchedType = TSLobsterAPI.Program.RequestQuery('SchedType');
        let doctId = TSLobsterAPI.Program.RequestQuery('doctId');
        let sdate = TSLobsterAPI.Program.RequestQuery('sdate');
        let edate = TSLobsterAPI.Program.RequestQuery('edate');

        var data = this.dao.gettableschedual(SchedType, doctId, sdate, edate, pageInfo);

        return { data: data, count: pageInfo.totalRecord };
    }

    stopschedual() {
        let schedId = TSLobsterAPI.Program.RequestQuery('schedId');
        let flag = TSLobsterAPI.Program.RequestQuery('flag');

        this.dao.stopschedual(schedId, flag);
        return { result: true };
    }

    setdoctorprice() {
        var model = JSON.parse(TSLobsterAPI.Program.RequestBody());
        this.dao.setdoctorprice(model.Id, model.RegPrice, model.IHPrice);
        return { result: true };
    }
}